<template>
    <uni-forms-item :required="formItem.required"
                    :label="formItem.label"
                    :name="formItem.name" :class="'st-uni-forms-item_'+ formItem.eType">
        <uni-easyinput v-if="formItem.eType==='TEXT'" :type="formItem.type?formItem.type: 'text'"
                       v-model="formData[formItem.name]"
                       :autoHeight="formItem.autoHeight"
                       :maxlength="formItem.maxlength"
                       :clearSize="formItem.clearSize"
                       :prefixIcon="formItem.prefixIcon"
                       :suffixIcon="formItem.suffixIcon"
                       :trim="formItem.trim"
                       :inputBorder="formItem.inputBorder"
                       :styles="formItem.styles"
                       :disabled="formItem.disabled"
                       :readonly="formItem.readonly"
                       :placeholder="formItem.placeholder? formItem.placeholder: ('请输入' + formItem.label)"/>
        <uni-number-box v-if="formItem.eType==='NUMBER'"
                        v-model="formData[formItem.name]"
                        :min="formItem.min"
                        :step="formItem.step"
                        :disabled="formItem.disabled"
                        :max="formItem.max"/>
        <uni-combox v-if="formItem.eType==='COMBOX'"
                    v-model="formData[formItem.name]"
                    :label="formItem.label"
                    :placeholder="formItem.placeholder"
                    :emptyTips="formItem.emptyTips"
                    :candidates="formItem.candidates"
                    :readonly="formItem.readonly"
                    :disabled="formItem.disabled"/>
        <st-uni-checkbox v-if="formItem.eType==='CHECKBOX_DICT'"
                         v-model="formData[formItem.name]"
                         :multiple="formItem.multiple"
                         :min="formItem.min"
                         :max="formItem.max"
                         :type="formItem.type"
                         :items="formItem.data"/>
        <uni-data-checkbox v-if="formItem.eType==='CHECKBOX'"
                           v-model="formData[formItem.name]"
                           :multiple="formItem.multiple"
                           :min="formItem.min"
                           :max="formItem.max"
                           :localdata="formItem.data"/>
        <st-uni-datetime-picker v-if="formItem.eType==='DATE_PICKER'"
                                :type="formItem.type"
                                :disabled="formItem.disabled"
                                v-model="formData[formItem.name]"/>
        <st-uni-data-picker v-if="formItem.eType==='DATA_PICKER'"
                            :type="formItem.type"
                            :disabled="formItem.disabled"
                            :select-all="formItem.selectAll"
                            :popup-title="formItem.popupTitle"
                            :items="formItem.items"
                            v-model="formData[formItem.name]"/>
    </uni-forms-item>
</template>

<script>
    /**
     * uni-easyinput type :text/password/textarea(autoHeight)
     * DATE_PICKER type date/daterange/datetime/datetimerange
     */

    import StUniDataPicker from './StUniDataPicker'
    import StUniCheckbox from "./StUniCheckbox"
    import StUniDatetimePicker from './st-uni-datetime-picker/st-uni-datetime-picker'

    export default {
        name: 'StUniDynamicFormItem',
        components: {StUniCheckbox, StUniDataPicker, StUniDatetimePicker},
        props: {
            formItem: {
                type: Object,
                default: function () {
                    return {}
                }
            },
            formData: {
                type: Object,
            },
        },
        data() {
            return {}
        },
        onLoad() {
        },
        created() {
        },
        watch: {},
        methods: {}
    }
</script>

<style>

</style>
